<!doctype html>
<html>
<head>
    <meta charset="UTF-8"/>
    <title>全屏不全屏</title> js怎么做到全屏
</head>
<body>
<input id="fullScreen" type="button" value="全屏"/>
<input id="fullScreenNormal" type="button" value="正常"/>
</body>
<script>
    // 全屏
    document.getElementById("fullScreen").onclick = function () {
        if (document.documentElement.RequestFullScreen) {
            document.documentElement.RequestFullScreen();
        }
        //兼容火狐
        console.log(document.documentElement.mozRequestFullScreen)
        if (document.documentElement.mozRequestFullScreen) {
            document.documentElement.mozRequestFullScreen();
        }
        //兼容谷歌等可以webkitRequestFullScreen也可以webkitRequestFullscreen
        if (document.documentElement.webkitRequestFullScreen) {
            document.documentElement.webkitRequestFullScreen();
        }
        //兼容IE,只能写msRequestFullscreen
        if (document.documentElement.msRequestFullscreen) {
            document.documentElement.msRequestFullscreen();
        }
    }
    // 不全屏
    document.getElementById("fullScreenNormal").onclick = function () {
        if (document.exitFullScreen) {
            document.exitFullscreen()
        }
//     		//兼容火狐
//     		console.log(document.mozExitFullScreen)
        if (document.mozCancelFullScreen) {
            document.mozCancelFullScreen()
        }
//     		//兼容谷歌等
        if (document.webkitExitFullscreen) {
            document.webkitExitFullscreen()
        }
//     		//兼容IE
        if (document.msExitFullscreen) {
            document.msExitFullscreen()
        }
    }
</script>
</html>
